// 
//  antflvlink.js
//  firefox
//  
//  Created by Zak on 2008-06-12.
//  Copyright 2008 Ant.com. All rights reserved.
// 

/**
 * Contains values necessary to list and download a flv
 * @param origin    Where the flv came from
 * @param url       Link to the flv
 * @param name      Guessed name of the movie
 * @param header option header object for request the url
 */
top.AntFlvLink = function (obj)
{
	this.origin = obj.origin;
    this.url = obj.url;
    this.name = obj.name;
	this.doc = obj.doc;
	this.path = obj.path ? obj.path : "";
	this.date = obj.date ? obj.date : "N/A";
	this.filesize = obj.filesize ? obj.filesize : "N/A"

	if (obj.header)//optional parameter
		this.header = obj.header;
	else
		this.header = "";
}


AntFlvLink.prototype = 
{
	/**
	 * incrementFlvName ... transform name -> name2, name2 -> name3 ...
	 * @param flvLink
	 */
	incrementFlvName: function ()
	{
		var match = this.name.match("_([0-9]+)$");

		if (match && match.length > 1)
		{
			var inc = parseInt(match[1], 10) + 1;

			this.name = this.name.substring(0, this.name.length - match[1].length) + inc;
		}
		else
			this.name += "_1";
	},
}
